<template>
  <!-- Swiper -->
  <div class="swiper-container">
    <div class="swiper-wrapper">
      <div v-for="item in data" :key="item.id" class="swiper-slide">
        <img :src="item.pic" alt="" style="width: 200px; height: 200px" />
        <span>{{ "￥" + item.price }}</span>
        <p>火热领券中</p>
      </div>
    </div>
    <!-- Add Pagination -->
    <div class="swiper-pagination"></div>
  </div>
</template>

<script>
import Swiper from "swiper";
import "swiper/swiper-bundle.css";
export default {
  props: {
    data: {
      type: Array,
      required: true,
    },
  },

  mounted() {
    this.myswiper2 = new Swiper(".swiper-container", {
      slidesPerView: 3,
      spaceBetween: 30,
      observer: true, //修改swiper自己或子元素时，自动初始化swiper
      observeParents: true, //修改swiper的父元素时，自动初始化swiper
    });
  },
};
</script>

<style lang="scss" scoped>
img {
  border-radius: 20px;
  margin-top: 10px;
}
span {
  margin-left: 20px;
  font-size: 16px;
  margin-right: 10px;
  color: red;
}
p {
  width: 120px;
  height: 30px;
  line-height: 30px;
  font-size: 13px;
  color: gray;
  margin-left: 20px;
  margin-top: 5px;
  margin-bottom: 10px;
}
</style>